/*
* $Id: Wnd.cpp 28 2010-02-09 20:33:18Z volok-aleksej@yandex.ru $
*
* Copyright 2008 by Volokitin Alexey
* All rights reserved
*
*/
#include "Common/include.h"
#include "Wnd.h"

CWndImpl::CWndImpl(){}
CWndImpl::~CWndImpl(){}

long CWndImpl::Send( unsigned int nMessage, unsigned int wParam, long lParam )
{
	long res = 0;
	if(IsCreate())
		res = (long)dynamic_cast<CWnd*>(this)->SendMessage(nMessage, wParam, lParam);
	return res;
}
bool CWndImpl::Post(unsigned int nMessage, unsigned int wParam, long lParam){
	bool res = false;
	if(IsCreate())
		res = dynamic_cast<CWnd*>(this)->PostMessage(nMessage, wParam, lParam);
	return res;
}
void CWndImpl::Redraw(){
	if(IsCreate())
		dynamic_cast<CWnd*>(this)->Invalidate(true);
}
int CWndImpl::GetWinId(){
	int result = 0;
	if(IsCreate())
		result = dynamic_cast<CWnd*>(this)->GetDlgCtrlID();
	return result;
}
bool CWndImpl::IsCreate(){
	bool result = false;
	CWnd* wnd = dynamic_cast<CWnd*>(this);
	if(wnd)
		result = IsWindow(wnd->m_hWnd);
	return result;
}
void CWndImpl::Free(){
	delete this;
}

void CWndImpl::Resize(int x, int y, int cx, int cy){
	if(IsCreate())
		dynamic_cast<CWnd*>(this)->MoveWindow(x, y, cx, cy);
}

void CWndImpl::Focus(){
	if(IsCreate())
		dynamic_cast<CWnd*>(this)->SetFocus();
}